import Vue from 'vue'
import MintUI from 'mint-ui'
import 'mint-ui/lib/style.css'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App'
import router from './router'
import Vuex from 'vuex'
import iView from 'iview';
import 'iview/dist/styles/iview.css';


import './css/iconfont.css'
Vue.use(Vuex);
Vue.use(MintUI);
Vue.use(ElementUI);
Vue.use(iView);
Vue.config.productionTip = false;
const store = new Vuex.Store({
  state: {
    personMsg:{}, // 存储个人信息
    history:[],//接收搜索城市历史记录
    value: [],//接收搜索食品历史记录
    products:'',// 存储用户名
    site:'',// 修改地址搜索的城市名
    city:{}, //存储城市
    store:{}, // 存储传送过来店铺的信息
    valueName:'',//填写地址的名字
    valueSite1:'',//详细地址
    valueNumber:'',//手机号
    valueNumber1:'',//备选手机号
    text:'',//新增地址的按钮
    cityID:'',//城市id
    shopCar:[],// 购物车信息(商品及商品数量)
    goods:'',// 店家信息
    RemarksArr:[],// 订单备注
    nameOne:'',
    address:{},// 地址信息
    arr1:'',//食品分类
  },
  mutations: {
    // 个人信息
    personMassage(state, p){
      state.personMsg = p;
      localStorage.setItem("personObj", JSON.stringify(state.personMsg));
    },
    // 城市历史记录
    // history(state, payload) {
    //   let com =  payload;
    //   let list = JSON.parse(localStorage.getItem("arr") || '[]');
    //   list.unshift(com);
    //   let set = new Set(list);
    //   localStorage.setItem("arr", JSON.stringify(set));
    // },
    // 食品的历史记录
    search(state, v){
      state.value.push(v);
      let set = new Set(state.value);
      localStorage.setItem("values", JSON.stringify(set));
    },
    // 店铺的信息
    store(state, v){
      state.store = v;
      localStorage.setItem("storeObj", JSON.stringify(state.store));
    },
    event1(state, site){
      state.site = site;
    },
    getName(state,name){
      state.valueName = name;
    },
    getSite1(state,site1){
      state.valueSite1 = site1;
    },
    getNumber(state,number){
      state.valueNumber = number;
    },
    getNumber1(state,number1){
      state.valueNumber1 = number1;
    },
    button(state, i){
      state.text = i
    },
  },

});

new Vue({
  el: '#app',
  render: h => h(App),
  store,
  router,
  components: { App },
  template: '<App/>'
});

